% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/latlon_from_anything.R
\name{latlon_any_format}
\alias{latlon_any_format}
\title{Get lat/lon flexibly - from file, data.frame, data.table, or lat/lon vectors}
\usage{
latlon_any_format(
  anything,
  lon_if_used,
  interactiveprompt = TRUE,
  invalid_msg_table = FALSE
)
}
\arguments{
\item{anything}{If missing and interactive mode in RStudio, prompts user for file. Otherwise,
this can be a filename (csv or xlsx, with path), or data.frame/ data.table/ matrix,
or vector of longitudes (in which case y must be the latitudes).
File or data.frame/data.table/matrix must have columns called lat and lon, or names that can
be inferred to be that by latlon_infer()}

\item{lon_if_used}{If anything parameter is a vector of longitudes, lon_if_used must be the latitudes. Ignored otherwise.}

\item{interactiveprompt}{If TRUE (default) and in interactive mode not running shiny,
will prompt user for file if "anything" is missing.}

\item{invalid_msg_table}{Set to TRUE to add columns "valid" and "invalid_msg" to output}
}
\value{
A data.frame that has at least columns lon and lat (and others if they were in x)
}
\description{
Try to figure out if user provided latitude / longitude
as vectors, data.frame, file, or interactively pick file.
}
\details{
Also see closely related function \code{\link[=sitepoints_from_any]{sitepoints_from_any()}}.

This function relies on

\code{\link[=read_csv_or_xl]{read_csv_or_xl()}}  and

\code{\link[=latlon_df_clean]{latlon_df_clean()}}
which in turn uses \code{\link[=latlon_infer]{latlon_infer()}} \code{\link[=latlon_as.numeric]{latlon_as.numeric()}} \code{\link[=latlon_is.valid]{latlon_is.valid()}}

A draft function \code{\link[=read_and_clean_points]{read_and_clean_points()}} would a more general way to get points,

but is still work in progress... it is similar to latlon_from_anything()

except it also uses these functions:

\code{\link[=latlon_from_regid]{latlon_from_regid()}},  \code{\link[=latlon_from_programid]{latlon_from_programid()}}

and could eventually use  _from_naics() etc.

Even more generally, FIPS and shapefile inputs could be read through a
single wrapper function at some point.
}
\examples{
 latlon_from_anything(testpoints_10)
 latlon_from_anything(testpoints_10$lat, testpoints_10$lon)
 pts = c("33,-100", "32,-101")
 latlon_from_anything(pts)
 pts = data.frame(Longitude = testpoints_10$lon, Latitude = testpoints_10$lat)
 latlon_from_anything(pts)
 pts = data.table(Lat = testpoints_10$lat, Long = testpoints_10$lon)
 latlon_from_anything(pts)
 \dontrun{
 if (interactive()) {
   pts <- latlon_from_anything()
 }}
 \dontrun{
 pts = system.file("testdata/latlon/testpoints_10.xlsx", package = "EJAM")
 latlon_from_anything(pts)
 }
  

}
\seealso{
\code{\link[=sitepoints_from_any]{sitepoints_from_any()}} which is like this but also adds ejam_uniq_id column,
and see \code{\link[=read_csv_or_xl]{read_csv_or_xl()}} and \code{\link[=latlon_df_clean]{latlon_df_clean()}}
}
\keyword{internal}
